package com.uwang.library.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.alibaba.fastjson.JSON;
import com.uwang.library.model.MemberListModel;
import com.uwang.library.service.BorrowedRecordService;
import com.uwang.library.service.MemberListService;
import com.uwang.library.service.impl.BorrowedRecordServiceImpl;
import com.uwang.library.service.impl.MemberListServiceImpl;

@WebServlet("/bowList")
public class BorrowedRecordServlet extends HttpServlet{
	
	private static final long serialVersionUID = 1L;
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doGet(req, resp);
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		BorrowedRecordService bowService = new BorrowedRecordServiceImpl();
		req.setAttribute("bowList", bowService.bomList());
		req.getRequestDispatcher("/member-record-download.jsp").forward(req, resp);
		
		
		
		
		if("delete".equals(req.getParameter("commond"))) {
			int borrowId = Integer.parseInt(req.getParameter("id"));
			bowService.deletionRecord(borrowId);
			
			
			resp.setContentType("text/html; charset=utf-8");
			PrintWriter out = resp.getWriter();
			// 将JAVA对象给fastjson转换
			String json = JSON.toJSONString("1");
			out.write(json);
			out.flush();
			out.close();
		}
		
	}
	
	public static void main(String[] args) {
	}
}
